/*
 * ExtGL.h
 *
 *  Created on: Oct 16, 2013
 *      Author: alexandru
 */

#ifndef EXTGL_H_
#define EXTGL_H_

#ifdef __APPLE__
#  include <GLUT/glut.h>
#else
#  include <GL/glut.h>
#include <GL/glew.h>

#endif

#include <gl.h>


namespace ExtGL{

void drawPrimitive(){

	glBegin(GL_POLYGON);
	   glVertex2f(0.0, 0.0);
	   glVertex2f(0.0, 3.0);
	   glVertex2f(3.0, 3.0);
	   glVertex2f(4.0, 1.5);
	   glVertex2f(3.0, 0.0);
	glEnd();
}


void drawRectangle(){
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	    glBegin(GL_QUADS);
	        glColor3d(1,0,0);
	        glVertex3f(-1,-1,-10);
	        glColor3d(1,1,0);
	        glVertex3f(1,-1,-10);
	        glColor3d(1,1,1);
	        glVertex3f(1,1,-10);
	        glColor3d(0,1,1);
	        glVertex3f(-1,1,-10);
	    glEnd();

}




void drawCube(double rotate_x, double rotate_y, double tx){
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

		  // Reset transformations
		  glLoadIdentity();

		  // Other Transformations
		   glTranslatef( tx, 0.0, 0.0 );      // Not included
		  // glRotatef( 180, 0.0, 1.0, 0.0 );    // Not included

		  // Rotate when user changes rotate_x and rotate_y
		  glRotatef( rotate_x, 1.0, 0.0, 0.0 );
		  glRotatef( rotate_y, 0.0, 1.0, 0.0 );

		  // Other Transformations
		  // glScalef( 2.0, 2.0, 0.0 );          // Not included

		  //Multi-colored side - FRONT
		  glBegin(GL_POLYGON);

		  glColor3f( 1.0, 0.0, 0.0 );     glVertex3f(  0.5, -0.5, -0.5 );      // P1 is red
		  glColor3f( 0.0, 1.0, 0.0 );     glVertex3f(  0.5,  0.5, -0.5 );      // P2 is green
		  glColor3f( 0.0, 0.0, 1.0 );     glVertex3f( -0.5,  0.5, -0.5 );      // P3 is blue
		  glColor3f( 1.0, 0.0, 1.0 );     glVertex3f( -0.5, -0.5, -0.5 );      // P4 is purple

		  glEnd();

		  // White side - BACK
		  glBegin(GL_POLYGON);
		  glColor3f(   1.0,  1.0, 1.0 );
		  glVertex3f(  0.5, -0.5, 0.5 );
		  glVertex3f(  0.5,  0.5, 0.5 );
		  glVertex3f( -0.5,  0.5, 0.5 );
		  glVertex3f( -0.5, -0.5, 0.5 );
		  glEnd();

		  // Purple side - RIGHT
		  glBegin(GL_POLYGON);
		  glColor3f(  1.0,  0.0,  1.0 );
		  glVertex3f( 0.5, -0.5, -0.5 );
		  glVertex3f( 0.5,  0.5, -0.5 );
		  glVertex3f( 0.5,  0.5,  0.5 );
		  glVertex3f( 0.5, -0.5,  0.5 );
		  glEnd();

		  // Green side - LEFT
		  glBegin(GL_POLYGON);
		  glColor3f(   0.0,  1.0,  0.0 );
		  glVertex3f( -0.5, -0.5,  0.5 );
		  glVertex3f( -0.5,  0.5,  0.5 );
		  glVertex3f( -0.5,  0.5, -0.5 );
		  glVertex3f( -0.5, -0.5, -0.5 );
		  glEnd();

		  // Blue side - TOP
		  glBegin(GL_POLYGON);
		  glColor3f(   0.0,  0.0,  1.0 );
		  glVertex3f(  0.5,  0.5,  0.5 );
		  glVertex3f(  0.5,  0.5, -0.5 );
		  glVertex3f( -0.5,  0.5, -0.5 );
		  glVertex3f( -0.5,  0.5,  0.5 );
		  glEnd();

		  // Red side - BOTTOM
		  glBegin(GL_POLYGON);
		  glColor3f(   1.0,  0.0,  0.0 );
		  glVertex3f(  0.5, -0.5, -0.5 );
		  glVertex3f(  0.5, -0.5,  0.5 );
		  glVertex3f( -0.5, -0.5,  0.5 );
		  glVertex3f( -0.5, -0.5, -0.5 );
		  glEnd();

		  glFlush();

}



}




#endif /* EXTGL_H_ */
